package com.sy.structural.adapter.obj;

import com.sy.structural.adapter.Player;
import com.sy.structural.adapter.Translator;
import com.sy.structural.adapter.Zh_JPTranslate;

/**
 * 继承的方式合并 类结构模型
 * 通过继承方式适配转换了翻译器的功能
 */
public class JPMoviePlayerAdapter implements Player {

    private Translator translator = new Zh_JPTranslate();

    private Player player;

    public JPMoviePlayerAdapter(Player target) {
        player = target;
    }

    @Override
    public String play() {
        // 播放后返回字母
        String context = player.play();
        // 翻译字幕
        String translate = translator.translate(context);
        return translate;
    }
}
